package com.spider.method1reference;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

public class Demo4 {
    public static void main(String[] args) {
        //目标：理解构造器引用
        //创建接口的匿名内部类对象
//        CarFactory cf = new CarFactory() {
//            @Override
//            public Car getCar(String name) {
//                return new Car(name);
//            }
//        };
        CarFactory cf = Car::new;
        Car c1 = cf.getCar("保时捷");
        System.out.println(c1);
    }
}
//函数接口
@FunctionalInterface
interface CarFactory {
    Car getCar(String name);
}
@Data
@NoArgsConstructor
@AllArgsConstructor
class Car {
    private String name;
}
